import {Body, Controller, Delete, Get, Param, Patch, Post} from '@nestjs/common';
import {ApprovalService} from './approval.service';
import {CreateApprovalDto} from './dto/create-approval.dto';
import {UpdateApprovalDto} from './dto/update-approval.dto';
import {HandleApprovalDto} from "./dto/handle-approval.dto";

@Controller('approval')
export class ApprovalController {
    constructor(private readonly ApprovalService: ApprovalService) {
    }

    @Post()
    create(@Body() createApprovalDto: CreateApprovalDto) {
        return this.ApprovalService.create(createApprovalDto);
    }

    @Get()
    findAll() {
        return this.ApprovalService.findAll();
    }

    @Get('list/:id')
    findByUserId(@Param('id') id: string) {
        return this.ApprovalService.findByUserId(id);
    }

    @Get(':id')
    findOne(@Param('id') id: string) {
        return this.ApprovalService.findOne(id);
    }

    @Patch(':id')
    update(@Param('id') id: string, @Body() updateApprovalDto: UpdateApprovalDto) {
        return this.ApprovalService.update(id, updateApprovalDto);
    }

    @Delete(':id')
    remove(@Param('id') id: string) {
        return this.ApprovalService.remove(id);
    }

    @Post('/save-all-nodes')
    saveAllNodes(@Body() nodes: CreateApprovalDto[]) {
        return this.ApprovalService.saveAllNode(nodes)
    }
    @Post('/handle-approval')
    handleApproval(@Body() handleParam: HandleApprovalDto) {
        return this.ApprovalService.handleApproval(handleParam)
    }
}
